{% load static %}
{% include 'Header.html' %}
        <!-- ============================================================== -->
        <!-- end navbar -->
        <!-- ============================================================== -->
   
        <!-- ============================================================== -->
        <!-- end left sidebar -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- wrapper  -->
        <!-- ============================================================== -->
        {% csrf_token %}
        <div class="bootstrap-dark">
            <div class="dashboard-content">

                <div class="row">
                    <!-- ============================================================== -->
                    <!-- valifation types -->
                    <!-- ============================================================== -->
                    <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                        <div class="card">
                            <h5 class="card-header text-white">New Vulnerability</h5>
                            <div class="card-body">
                                <form id="validationform" method="POST" onsubmit="return addnewvulnerability(this);"action="" >{% csrf_token %}
                                    {{ from.media }}
                                    <input type="hidden" name="project"value="{{ project}}"></input>
                                    <div class="form-group row">
                                        <label class="col-12 col-sm-3 col-form-label text-sm-right text-white">Vulnerability Title</label>
                                        <div class="col-12 col-sm-8 col-lg-6">
                                                                                  
                                       
                                             

                                          <select name="vulnerabilityname" class="text-white"id="editable-select">
                                            
                                            {% for vuln in vulnerabilityDB %}
                                            <option>{{vuln.vulnerabilityname}}</option>
                                            {% endfor %}
                                          </select>
                                    </div>
                                </div>

                               
                                <div class="form-group row">
                                    <label class="col-12 col-sm-3 col-form-label text-sm-right text-white">Status</label>
                                    <div class="col-12 col-sm-8 col-lg-6">
                                    <select class="form-control text-white" id="input-select" required data-live-search="true" name="status">
                                        <option>Vulnerable</option>
                                        <option>Confirm Fixed</option>
                                    </select>
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-12 col-sm-3 col-form-label text-sm-right text-white">CVSS 3.1</label>
                                <div class="col-12 col-sm-8 col-lg-6">
                                    
                                    
                                    <!-- ///////////////////////////////////////// BEGIN TRANSLATED ///////////////////////////////////////// -->
                                    
                                    <fieldset id="baseMetricGroup">
                                      <legend id="baseMetricGroup_Legend" title="The Base Metric group represents the intrinsic  characteristics of a vulnerability that are constant over time and across user environments. Determine the vulnerable component and score Attack Vector, Attack Complexity, Privileges Required and User Interaction relative to this.">Base Score</legend>
                                    
                                      <div class="column column-left">
                                        <div class="metric">
                                          <input type="hidden" id="cvssvectionid" value="{{ form.cvssvector.value }}">
                                          <h3 id="AV_Heading" title="This metric reflects the context by which vulnerability exploitation is possible. The Base Score increases the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable component.">Attack Vector (AV)</h3>
                                          <input name="AV" value="N" id="AV_N" onclick="updateScores()" type="radio"><label for="AV_N" id="AV_N_Label" title="A vulnerability exploitable with network access means the vulnerable component is bound to the network stack and the attacker's path is through OSI layer 3 (the network layer). Such a vulnerability is often termed &quot;remotely exploitable” and can be thought of as an attack being exploitable one or more network hops away.">Network (N)</label>
                                          <input name="AV" value="A" id="AV_A" onclick="updateScores()"type="radio"><label for="AV_A" id="AV_A_Label" title="A vulnerability exploitable with adjacent network access means the vulnerable component is bound to the network stack, however the attack is limited to the same shared physical (e.g. Bluetooth, IEEE 802.11), or logical (e.g. local IP subnet) network, and cannot be performed across an OSI layer 3 boundary (e.g. a router).">Adjacent (A)</label>
                                          <input name="AV" value="L" id="AV_L" onclick="updateScores()"type="radio"><label for="AV_L" id="AV_L_Label" title="A vulnerability exploitable with local access means that the vulnerable component is not bound to the network stack, and the attacker's path is via read/write/execute capabilities. In some cases, the attacker may be logged in locally in order to exploit the vulnerability, otherwise, she may rely on User Interaction to execute a malicious file.">Local (L)</label>
                                          <input name="AV" value="P" id="AV_P" onclick="updateScores()"type="radio"><label for="AV_P" id="AV_P_Label" title="A vulnerability exploitable with physical access requires the attacker to physically touch or manipulate the vulnerable component. Physical interaction may be brief or persistent.">Physical (P)</label>
                                        </div>
                                    
                                        <div class="metric">
                                          <h3 id="AC_Heading" title="This metric describes the conditions beyond the attacker's control that must exist in order to exploit the vulnerability. Such conditions may require the collection of more information about the target, the presence of certain system configuration settings, or computational exceptions.">Attack Complexity (AC)</h3>
                                          <input name="AC" value="L" id="AC_L" onclick="updateScores()"type="radio"><label for="AC_L" id="AC_L_Label" title="Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success against the vulnerable component.">Low (L)</label>
                                          <input name="AC" value="H" id="AC_H" onclick="updateScores()"type="radio"><label for="AC_H" id="AC_H_Label" title="A successful attack depends on conditions beyond the attacker's control. That is, a successful attack cannot be accomplished at will, but requires the attacker to invest in some measurable amount of effort in preparation or execution against the vulnerable component before a successful attack can be expected. For example, a successful attack may require the attacker: to perform target-specific reconnaissance; to prepare the target environment to improve exploit reliability; or to inject herself into the logical network path between the target and the resource requested by the victim in order to read and/or modify network communications (e.g. a man in the middle attack).">High (H)</label>
                                        </div>
                                    
                                        <div class="metric">
                                          <h3 id="PR_Heading" title="This metric describes the level of privileges an attacker must possess before successfully exploiting the vulnerability. This Base Score increases as fewer privileges are required.">Privileges Required (PR)</h3>
                                          <input name="PR" value="N" id="PR_N" onclick="updateScores()"type="radio"><label for="PR_N" id="PR_N_Label" title="The attacker is unauthorized prior to attack, and therefore does not require any access to settings or files to carry out an attack.">None (N)</label>
                                          <input name="PR" value="L" id="PR_L" onclick="updateScores()"type="radio"><label for="PR_L" id="PR_L_Label" title="The attacker is authorized with (i.e. requires) privileges that provide basic user capabilities that could normally affect only settings and files owned by a user. Alternatively, an attacker with Low privileges may have the ability to cause an impact only to non-sensitive resources.">Low (L)</label>
                                          <input name="PR" value="H" id="PR_H" onclick="updateScores()"type="radio"><label for="PR_H" id="PR_H_Label" title="The attacker is authorized with (i.e. requires) privileges that provide significant (e.g. administrative) control over the vulnerable component that could affect component-wide settings and files.">High (H)</label>
                                        </div>
                                    
                                        <div class="metric">
                                          <h3 id="UI_Heading" title="This metric captures the requirement for a user, other than the attacker, to participate in the successful compromise the vulnerable component. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner. The Base Score is highest when no user interaction is required.">User Interaction (UI)</h3>
                                          <input name="UI" value="N" id="UI_N" onclick="updateScores()"type="radio"><label for="UI_N" id="UI_N_Label" title="The vulnerable system can be exploited without any interaction from any user.">None (N)</label>
                                          <input name="UI" value="R" id="UI_R" onclick="updateScores()"type="radio"><label for="UI_R" id="UI_R_Label" title="Successful exploitation of this vulnerability requires a user to take some action before the vulnerability can be exploited.">Required (R)</label>
                                        </div>
                                      </div>
                                    
                                      <div class="column column-right">
                                        <div class="metric">
                                          <h3 id="S_Heading" title="Does a successful attack impact a component other than the vulnerable component? If so, the Base Score increases and the Confidentiality, Integrity and Authentication metrics should be scored relative to the impacted component.">Scope (S)</h3>
                                          <input name="S" value="U" id="S_U" onclick="updateScores()"type="radio"><label for="S_U" id="S_U_Label" title="An exploited vulnerability can only affect resources managed by the same authority. In this case the vulnerable component and the impacted component are the same.">Unchanged (U)</label>
                                          <input name="S" value="C" id="S_C" onclick="updateScores()"type="radio"><label for="S_C" id="S_C_Label" title="An exploited vulnerability can affect resources beyond the authorization privileges intended by the vulnerable component. In this case the vulnerable component and the impacted component are different.">Changed (C)</label>
                                        </div>
                                    
                                        <div class="metric">
                                          <h3 id="C_Heading" title="This metric measures the impact to the confidentiality of the information resources managed by a software component due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.">Confidentiality (C)</h3>
                                          <input name="C" value="N" id="C_N" onclick="updateScores()"type="radio"><label for="C_N" id="C_N_Label" title="There is no loss of confidentiality within the impacted component.">None (N)</label>
                                          <input name="C" value="L" id="C_L" onclick="updateScores()"type="radio"><label for="C_L" id="C_L_Label" title="There is some loss of confidentiality. Access to some restricted information is obtained, but the attacker does not have control over what information is obtained, or the amount or kind of loss is constrained. The information disclosure does not cause a direct, serious loss to the impacted component.">Low (L)</label>
                                          <input name="C" value="H" id="C_H" onclick="updateScores()"type="radio"><label for="C_H" id="C_H_Label" title="There is total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact.">High (H)</label>
                                        </div>
                                    
                                        <div class="metric">
                                          <h3 id="I_Heading" title="This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information.">Integrity (I)</h3>
                                          <input name="I" value="N" id="I_N" onclick="updateScores()"type="radio"><label for="I_N" id="I_N_Label" title="There is no loss of integrity within the impacted component.">None (N)</label>
                                          <input name="I" value="L" id="I_L" onclick="updateScores()"type="radio"><label for="I_L" id="I_L_Label" title="Modification of data is possible, but the attacker does not have control over the consequence of a modification, or the amount of modification is constrained. The data modification does not have a direct, serious impact on the impacted component.">Low (L)</label>
                                          <input name="I" value="H" id="I_H" onclick="updateScores()"type="radio"><label for="I_H" id="I_H_Label" title="There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any/all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component.">High (H)</label>
                                        </div>
                                    
                                        <div class="metric">
                                          <h3 id="A_Heading" title="This metric measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability. It refers to the loss of availability of the impacted component itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of an impacted component.">Availability (A)</h3>
                                          <input name="A" value="N" id="A_N" onclick="updateScores()"type="radio"><label for="A_N" id="A_N_Label" title="There is no impact to availability within the impacted component.">None (N)</label>
                                          <input name="A" value="L" id="A_L" onclick="updateScores()"type="radio"><label for="A_L" id="A_L_Label" title="There is reduced performance or interruptions in resource availability. Even if repeated exploitation of the vulnerability is possible, the attacker does not have the ability to completely deny service to legitimate users. The resources in the impacted component are either partially available all of the time, or fully available only some of the time, but overall there is no direct, serious consequence to the impacted component.">Low (L)</label>
                                          <input name="A" value="H" id="A_H" onclick="updateScores()"type="radio"><label for="A_H" id="A_H_Label" title="There is total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component (e.g., the attacker cannot disrupt existing connections, but can prevent new connections; the attacker can repeatedly exploit a vulnerability that, in each instance of a successful attack, leaks a only small amount of memory, but after repeated exploitation causes a service to become completely unavailable).">High (H)</label>
                                        </div>
                                      </div>
                                    
                                      <div class="scoreRating">
                                        <p class="needBaseMetrics">Select values for all base metrics to generate score</p>
                                        <span id="baseMetricScore"></span>
                                        <span id="baseSeverity"></span>
                                      </div>
                                    </fieldset>
                                    <div class="end"></div>
                                    
                                    
                                    <fieldset style="background:#090; color:#ffffff; border-radius:10px">
                                      <p id="vector">Vector String -
                                        <span class="needBaseMetrics">select values for all base metrics to generate a vector</span>
                                        <input id="vectorString" required readonly="" type="text">
                                      </p>
                                    </fieldset>
                                    
                                    
                                    
                                    
                                      
                                    </fieldset>
                                    <div class="end"></div>
                            </div>
                        </div>
                                    <div class="form-group row">
                                        <label class="col-12 col-sm-3 col-form-label text-sm-right text-white">Vulnerability Description</label>
                                        <div class="col-12 col-sm-8 col-lg-6">
                                            
                                            {{ form.vulnerabilitydescription }}
                                
                                           
                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label class="col-12 col-sm-3 col-form-label text-sm-right text-white">Proof Of Concept</label>
                                        <div class="col-12 col-sm-8 col-lg-6">
                                            
                                            {{ form.POC }}
                                
                                           
                                        </div>
                                    </div>
                                    
                                    <div class="form-group row">
                                        <label class="col-12 col-sm-3 col-form-label text-sm-right text-white">Vulnerability Solution</label>
                                        <div class="col-12 col-sm-8 col-lg-6">
                                            
                                            {{ form.vulnerabilitysolution }}
                                
                                           
                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label class="col-12 col-sm-3 col-form-label text-sm-right text-white">Reference Link</label>
                                        <div class="col-12 col-sm-8 col-lg-6">
                                            
                                            {{ form.vulnerabilityreferlnk }}
                                
                                           
                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label class="col-12 col-sm-3 col-form-label text-sm-right text-white">Vulnerable URL</label>
                                        <div class="col-12 col-sm-8 col-lg-6">
                                            
                                            <div class="table-responsive display">
                                                <a role="button" class="btn btn-primary align-items-center text-white" data-toggle="modal" data-target="#addnew">Add New</a>
                                                <table id="addinstancetable" class="table" >
                                                    
                                                    <thead class="">
                                                        <tr class="border-0">
                                                            <th class="border-0 text-white">#</th>
                                                            <th class="border-0 text-white">URL</th>
                                                            <th class="border-0 text-white">Paramter</th>
                                                           
                                                            <th class="border-0 text-white">Delete</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                       
    
                                                    
                                                    
    
    
    
    
                                                       
                                                       
                                                    </tbody>
                                                </table>
                                            </div>
                                           
                                        </div>
                                    </div>


                                   
                                    
                             

                                    <div class="form-group row text-right">
                                        <div class="col col-sm-10 col-lg-9 offset-sm-1 offset-lg-0">
                                            <input type="submit" class="btn btn-space btn-primary" value="Submit">
                                            
                                            
                                          
                                            <button type="button" class="btn btn-space btn-secondary"onclick="history.back()">Cancel</button>

                                        </div>
                                    </div>
                                </form>
                                
                            </div>
                        </div>
                    </div>
                    <!-- ============================================================== -->
                    <!-- end valifation types -->
                    <!-- ============================================================== -->
                </div>
                
                
                <div class="modal fade" id="addnew" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                    <div class="modal-dialog" role="document">
                      <div class="modal-content">
                        <div class="modal-header">
                          <h5 class="modal-title" id="exampleModalLabel">URLS</h5>
                          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                          </button>
                        </div>
                        <div class="modal-body">
                            <label class="col-12 col-sm-3 col-form-label text-white">URL</label>
                            <input type="text" name="name" id="newurl" placeholder="Type something" class="form-control" required >
                            <label class="col-12 col-sm-3 col-form-label text-white">Paramter</label>
                            <input type="text" name="name" id="NewParamter" placeholder="Type something" class="form-control" required >
                        </div>
                        <div class="modal-footer">
                          <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                          <button type="button" class="btn btn-primary" onclick="addinstacerowfunction()" id="addnewurl">Save changes</button>
                        </div>
                      </div>
                    </div>
                  </div>


                  


                       
                    <!-- ============================================================== -->
                    <!-- end sidenavbar -->
                    <!-- ============================================================== -->
                </div>
            </div>
            <!-- ============================================================== -->
            <!-- footer -->
            <!-- ============================================================== -->
            <div class="footer bootstrap-dark">
                <div class="container-fluid bootstrap-dark">
                    <div class="row">
                        <div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 col-12">
                            Copyright © 2022 APTRS. All rights reserved. Dashboard by <a href="https://colorlib.com/wp/">Colorlib</a>.
                        </div>
                        
                    </div>
                </div>
            </div>
            <!-- ============================================================== -->
            <!-- end footer -->
            <!-- ============================================================== -->
        </div>
    </div>
    <!-- ============================================================== -->
    <!-- end main wrapper -->
    <!-- ============================================================== -->
    <!-- Optional JavaScript -->
    <script src="{% static "vendor/jquery/jquery-3.3.1.min.js" %}"></script>
    <script src="{% static "vendor/bootstrap/js/bootstrap.bundle.js" %}"></script>
    <script src="{% static "libs/js/main.js" %}"></script>
    <script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
  <script src="https://cdn.datatables.net/1.12.1/js/dataTables.bootstrap4.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/table-to-json@1.0.0/lib/jquery.tabletojson.min.js"></script>
    <script type="text/javascript" src="{% static "ckeditor/ckeditor-init.js" %}"></script>
<script type="text/javascript" src="{% static "ckeditor/ckeditor/ckeditor.js" %}"></script>
<script src="{% static "libs/js/cvsscalc31.js" %}"></script>
<script src="{% static "libs/js/cvsscalc31_helptext.js" %}"></script>
<script src="{% static "libs/js/cvsscalculator31.js" %}"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

<script src="//rawgithub.com/indrimuska/jquery-editable-select/master/dist/jquery-editable-select.min.js"></script>


<script>
  $('#editable-select').change(function(){
    //alert($(this).val());
    var http = new XMLHttpRequest();
    var params = 'title='+encodeURIComponent($(this).val());
    var url = '/project/fetch/vulnerability?'+params;
    
    http.open('GET', url, true);
    http.onreadystatechange = function() {//Call a function when the state changes.
        if(http.readyState == 4 && http.status == 200) {
            //alert(http.responseText);
            var Data = JSON.parse(http.responseText);
            //console.log(Data.Description)
            //document.getElementById("id_vulnerabilitydescription").inn
            CKEDITOR.instances['id_vulnerabilitydescription'].setData(Data.Description);
            CKEDITOR.instances['id_vulnerabilitysolution'].setData(Data.solution);
            CKEDITOR.instances['id_vulnerabilityreferlnk'].setData(Data.refer);
            //const $select = document.querySelector('#select-Severity');
            //$select.value = Data.severity
            document.getElementById('cvssvectionid').value = Data.vector
            cvssclaconload()
            
            
        }
    }
    http.send();
})
</script>
<script>
  $('#editable-select').editableSelect({ effects: 'default' });

 </script>
</body>
</html>
